/*
 * @ClassName router_register.dart
 * @Description 路由注册
 * @Author SuPeiSen
 * @Date 2020/7/15 15:07
 */

import 'package:fluro/fluro.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_su/router/Audit_router.dart';
import 'package:flutter_su/router/login_register_router.dart';
import 'package:flutter_su/router/router_not_find.dart';
import 'package:flutter_su/router/test_router.dart';

import 'base_router.dart';

class RouterRegister {
  //子router管理集合
  static List<BaseRouter> _listRouter = [];

  static void configureRoutes(Router router) {
    /// 指定路由跳转错误返回页
    router.notFoundHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
        return RouterNotFind();
      },
    );

    //每次初始化前 先清除集合 以免重复添加
    _listRouter.clear();

    _listRouter.add(TestRouter());

    _listRouter.add(LoginRegisterRouter());

    _listRouter.add(AuditRouter());

    /// 初始化路由 循环遍历取出每个子router进行初始化操作
    _listRouter.forEach((routerItem) {
      routerItem.initRouter(router);
    });
  }
}
